package com.coding.controller;

import com.coding.base.pojo.BaseModel;
import com.coding.pojo.Studyplan;
import com.coding.service.StudyPlanService;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @auther wangchenghao
 * @date 2020/8/16
 **/
@Controller
@ResponseBody
@RequestMapping("studyplan")
public class StudyPlanController {
    @Autowired
    StudyPlanService studyPlanService;

    @ApiOperation("查询学习任务")
    @RequestMapping(value = "/getList", method = {RequestMethod.GET})
    public BaseModel getList(@ApiParam("user_id") @RequestParam(value = "user_id", required = true) int user_id
    ) throws Exception {
        BaseModel model = new BaseModel();
        studyPlanService.getUserPlan(user_id, model);
        return model;
    }

    @ApiOperation("新创任务")
    @RequestMapping(value = "/insert", method = {RequestMethod.POST})
    public BaseModel insert(@ModelAttribute Studyplan studyplan) throws Exception {
        BaseModel model = new BaseModel();
        studyPlanService.insertPlan(studyplan, model);
        return model;
    }
}
